package com.lixinxin.commoncomposeproject.screen

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.lixinxin.commoncomposeproject.model.Article

/**
 *   author ： lixinxin
 *   time    ： 2021-11-19
 *   email：895330766@qq.com
 */


@Composable
fun IndexScreen(navController: NavController) {

    val datas: List<Article> = listOf()

    Surface(
        Modifier
            .fillMaxWidth()
            .fillMaxHeight()
    ) {
        Box(
            Modifier
                .fillMaxWidth()
                .fillMaxHeight()
        ) {
            LazyColumn(
                Modifier.fillMaxWidth(),
                verticalArrangement = Arrangement.spacedBy(8.dp)
            ) {
                items(datas) { data ->
                    ArticleItemView(data)
                }
            }
        }
    }
}

@Composable
fun ArticleItemView(article: Article) {

    Row(
        Modifier
            .fillMaxWidth()
            .defaultMinSize(minHeight = 60.dp)
            .background(color = Color.LightGray)
    ) {
//        Image(
//            painter = rememberVectorPainter(id = R.mipmap.ic_launcher),
//            contentDescription = "image",
//            Modifier
//                .width(40.dp)
//                .height(40.dp)
//        )
        Text(text = article.title)
    }

}


@Preview(showBackground = true)
@Composable
fun ComposeTextPreview() {

    Surface() {
        Text(text = "Hello World", fontSize = 20.sp, color = Color.Red)
    }


}



